package itheima.d05;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

public class Test {
    public static void main(String[] args) throws IOException {

        try (


        FileReader fr = new FileReader("C:\\Users\\胡文冰\\Desktop\\haiyan.txt");
        BufferedReader br = new BufferedReader(fr);


        FileWriter fw = new FileWriter("C:\\Users\\胡文冰\\Desktop\\haiyan2.txt");
        BufferedWriter bw = new BufferedWriter(fw);
        ){
            ArrayList<String> list = new ArrayList<>();
            String line;
            while ((line = br.readLine()) != null) {
                list.add(line);
            }
            list.forEach(System.out::println);

            Collections.sort(list);
            for (String data : list) {
                bw.write(data);
                bw.newLine();

            }
        }catch ( Exception e){
            throw new RuntimeException(e);
        }

    }
}
